<?php
namespace Admin\Controller;

use Think\Controller;

class PromptController extends AclController {
    // PC 获取用户
    public function getPrompt($page=1,$rows=20,$no=''){
    	$prompt = M('prompt','tlsys_','DB_REMOTE_WC');
        //筛选条件
        $condition=array();
        if(!empty($no)){
            $condition['no']=array('like','%'.$no.'%');
        }
        //取哪几条
        $limit=($page-1)*$rows.','.$rows;
        //总条数
        $count=$prompt->where($condition)->count();
        //行数据
    	$data=$prompt->where($condition)->order(" id desc ")->limit($limit)->select();
    	// echo $user->getLastSql();
        $this->ajaxReturn(array('total'=>$count,'rows'=>$data));
    }

    function addPrompt($us=''){      
        $prompt=M('prompt','tlsys_','DB_REMOTE_WC');
        //判断是否已经存在该卡号
        $no=$_POST['cardno'];
        $count=$prompt->where("cardno='{$no}'")->count();
        if($count>0){
            echo -1;
        }else{
             $prompt->create();
            $prompt->inserttime=time();
            $prompt->lastupdatetime=time();

            $res=$prompt->add();
            echo $res;
        }       
    }
    function updatePrompt($us=''){
        //用户登陆信息
        $prompt=M('prompt','tlsys_','DB_REMOTE_WC');
        $data['no']=$_POST['no'];
        $data['amount']=$_POST['amount'];
        $data['mark']=$_POST['mark'];
        $data['lastupdatetime']=time();

        $res=$prompt->where(array('id'=>$_POST['id']))->data($data)->save();

        echo $res;
    }

    function deletePrompt($id=0){
        $prompt=M('prompt','tlsys_','DB_REMOTE_WC');
        $res=$prompt->delete($id);
        echo $res;
    }
}